package com.yuanheng100.ems4j.mapper;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import com.yuanheng100.ems4j.model.Ems4jDict;
import org.mybatis.caches.ehcache.EhcacheCache;

@CacheNamespace(implementation = EhcacheCache.class)
public interface Ems4jDictMapper {

    @Insert({
        "insert into ems4j_dict (dictid, dictkey, ",
        "dictvalue, appid, ",
        "dictstatus)",
        "values (#{dictid,jdbcType=INTEGER}, #{dictkey,jdbcType=VARCHAR}, ",
        "#{dictvalue,jdbcType=VARCHAR}, #{appid,jdbcType=INTEGER}, ",
        "#{dictstatus,jdbcType=SMALLINT})"
    })
    int insert(Ems4jDict record);


    @Select({
        "select",
        "dictid, dictkey, dictvalue, appid, dictstatus",
        "from ems4j_dict",
        "where dictid = #{dictid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="dictid", property="dictid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="dictkey", property="dictkey", jdbcType=JdbcType.VARCHAR),
        @Result(column="dictvalue", property="dictvalue", jdbcType=JdbcType.VARCHAR),
        @Result(column="appid", property="appid", jdbcType=JdbcType.INTEGER),
        @Result(column="dictstatus", property="dictstatus", jdbcType=JdbcType.SMALLINT)
    })
    Ems4jDict selectByPrimaryKey(Integer dictid);


    @Update({
        "update ems4j_dict",
        "set dictkey = #{dictkey,jdbcType=VARCHAR},",
          "dictvalue = #{dictvalue,jdbcType=VARCHAR},",
          "appid = #{appid,jdbcType=INTEGER},",
          "dictstatus = #{dictstatus,jdbcType=SMALLINT}",
        "where dictid = #{dictid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Ems4jDict record);
}